package cn.edu.cqu.fredyvia.forum.mapper;

import cn.edu.cqu.fredyvia.forum.dto.CommentDTO;
import cn.edu.cqu.fredyvia.forum.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author fredyvia
 * @since 2021-07-10
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("SELECT `comment`.id,content,create_datetime,username,avatar FROM (`comment` LEFT JOIN `user` ON `user`.id = `comment`.user_id) LEFT JOIN `user_info` ON `user_info`.user_id = `user`.id WHERE talk_id=${talkId};")
    List<CommentDTO> listByTalkId(@Param("talkId") int talkId);
    @Select("SELECT id,content,create_datetime, FROM `comment`  WHERE id=${commentId};")
    CommentDTO one(@Param("commentId") int commentId);
}
